package com.bwie.list.service.impl;

import com.bwie.common.domain.Data1;
import com.bwie.common.domain.Data2;
import com.bwie.common.domain.Data3;
import com.bwie.list.mapper.TestMapper;
import com.bwie.list.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestServiceImpl implements TestService {
    @Autowired
    private TestMapper testMapper;

    @Override
    public void addData1(Data1 data1) {
        Data1 data1ById = testMapper.findData1ById(data1.getId());
        if(data1ById==null){
            testMapper.addData1(data1);
        }else {
            testMapper.updData1(data1);
        }
    }

    @Override
    public void addData2(Data2 data2) {
        Data2 data2ById = testMapper.findData2ById(data2.getId());
        if(data2ById==null){
            testMapper.addData2(data2);
        }else {
            testMapper.updData2(data2);
        }
    }

    @Override
    public void addData3(Data3 data3) {
        Data3 data3ById = testMapper.findData3ById(data3.getId());
        if(data3ById==null){
            testMapper.addData3(data3);
        }else {
            testMapper.updData3(data3);
        }
    }

    @Override
    public List<Data1> findData1All() {
        return testMapper.findData1All();
    }

    @Override
    public Data1 findData1ByTime(String dataEndTime) {
        return testMapper.findData1ByTime(dataEndTime);
    }
}
